package com.wing.cabinet.model.entity;

import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 统计限额
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("cab_count_quota")
public class CountQuota extends BaseEntity<CountQuota> implements Serializable {

    private static final long serialVersionUID = 1L;

    public enum CreditWay implements IEnum<Integer> {

        /**
        * 组员共享领用金额
        */
        share(0,"组员共享领用金额"),
        /**
        * 组员独立授信领用金额
        */
        independent(1,"组员独立授信领用金额"),
        /**
        * 不限制领用金额
        */
        unlimited(2,"不限制领用金额"),
        /**
         * 组员共享领用数量
         */
        shareQuantity(3,"组员共享领用数量"),
        /**
         * 组员独立授信领用数量
         */
        independentQuantity(4,"组员独立授信领用数量"),
        /**
         * 不限制领用数量
         */
        unlimitedQuantity(5,"不限制领用数量");

        private int code;
        private String desc;

        CreditWay(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }

    public enum LineEvaluatePeriod implements IEnum<Integer> {

        /**
        * 每天
        */
        day(0,"每天"),
        /**
        * 每周
        */
        week(1,"每周"),
        /**
        * 每月
        */
        month(2,"每月"),
        /**
        * 每季度
        */
        quarter(3,"每季度"),
        /**
        * 每年
        */
        year(4,"每年");

        private int code;
        private String desc;

        LineEvaluatePeriod(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }

    public enum CreditType implements IEnum<Integer> {
        /**
         * 金额
         */
        money(0,"金额"),
        /**
         * 数量
         */
        quantity(1,"数量");

        private int code;
        private String desc;

        CreditType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 权限组Id
     */
    private Long authorityManageId;

    /**
     * 领取人Id
     */
    private Long receiverId;

    /**
     * 领取人
     */
    private String receiverName;

    /**
     * 授信方式
     */
    private CreditWay creditWay;

    /**
    * 授信方式描述
    */
    @TableField(exist = false)
    private String creditWayDesc;

    public String getCreditWayDesc() {
        return creditWay == null ? null : creditWay.getDesc();
    }

    /**
     * 额度评估周期
     */
    private LineEvaluatePeriod lineEvaluatePeriod;

    /**
    * 额度评估周期描述
    */
    @TableField(exist = false)
    private String lineEvaluatePeriodDesc;

    public String getLineEvaluatePeriodDesc() {
        return lineEvaluatePeriod == null ? null : lineEvaluatePeriod.getDesc();
    }

    /**
     * 授信额度
     */
    private BigDecimal lineOfCredit;

    /**
     * 剩余可领金额
     */
    private BigDecimal balance;

    /**
     * 授信数量
     */
    private Integer authorizedQuantity;

    /**
     * 剩余可领数量
     */
    private Integer residualQuantity;

    /**
     * 授信类型
     */
    private CreditType creditType;

    /**
     * 授信类型描述
     */
    @TableField(exist = false)
    private String creditTypeDesc;

    public String getCreditTypeDesc() {
        return creditType == null ? null : creditType.getDesc();
    }
    /**
     * skuCode
     */
    private String skuCode;
    /**
     * 可领金额/数量下次重置更新时间
     */
    @JsonFormat(timezone = "GMT+8" , pattern = "yyyy-MM-dd HH:mm:ss" )
    private LocalDateTime resetTime;
}
